package com.xym.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.xym.pojo.Item;
import com.xym.pojo.ItemDesc;
import com.xym.web.Service.ItemService;

@Controller
@RequestMapping("item")
public class ItemController {

	@Autowired
	private ItemService itemService;
	
	@RequestMapping(value="{itemid}")
	public ModelAndView queryItemById(@PathVariable("itemid")Long itemId){
		ModelAndView view = new ModelAndView("item");
		Item item=null;
		ItemDesc itemDesc =null;
		try {
			item = itemService.queryItem(itemId);
			itemDesc=itemService.queryItemDesc(itemId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		view.addObject("item", item);
		view.addObject("itemDesc", itemDesc);
		return view;
	}
}
